package pl.edu.agh.iosr.gamblingzone.dao.ejb;

import java.util.List;

import pl.edu.agh.iosr.gamblingzone.dao.QuoteDAO;
import pl.edu.agh.iosr.gamblingzone.model.Quote;

/**
 * The Class QuoteDAOBean.
 */
public class QuoteDAOBean extends GenericDAOBean<Quote, Long> 
		implements QuoteDAO {
	
	/** The quote list. */
	List<Quote> quoteList = null;

	/* (non-Javadoc)
	 * @see pl.edu.agh.iosr.gamblingzone.dao.QuoteDAO#getRandomQuote()
	 */
	public Quote getRandomQuote() {
		if(quoteList == null) {
			quoteList = findAll();
		}
		
		return quoteList.get((int)Math.round(Math.random()*(quoteList.size()-1)));
	}
	
}